package com.aliyun.heiyu.powermaster.server.rotary.task;

import com.aliyun.heiyu.powermaster.server.rotary.service.WarnService;
import com.aliyun.heiyu.powermaster.server.rotary.service.impl.AirServiceImpl;
import com.aliyun.heiyu.powermaster.server.rotary.service.impl.WarnServiceImpl;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

/**
 * @Description 心跳任务
 * @Author shun.zhang
 * @Date 2020/1/9 14:50
 **/
public class HeartbeatTask implements Job {
    private static Logger logger = LoggerFactory.getLogger(HeartbeatTask.class);
    private WarnService warnService = new WarnServiceImpl();
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("{}: 执行心跳检测任务",new Date());
        if(!AirServiceImpl.isRatoryStatus()){
            logger.info("动环状态处于关闭状态");
            return;
        }
        warnService.heartbeat();
    }
}
